import tinymce from 'tinymce/tinymce'
import { docPreview } from '@/api'
import { saveBeforeExport } from '@/utils/helpers'

tinymce.PluginManager.add('docPreview', function (editor) {
  return (
    editor.ui.registry.addMenuItem('docPreview', {
      text: '预览',
      async onAction() {
        // await saveBeforeExport()
        docPreview()
      }
    }),
    {
      getMetadata: function () {
        return {
          name: '预览',
          url: 'http://sfrj.cn'
        }
      }
    }
  )
})
